// set方法
function uniqueSet(arr) {
  let set = new Set(arr);
  return Array.from(set);
}

// indexOf方法
function uniqueIndexOf(arr) {
  let result = [];
  for (let i = 0; i < arr.length; i++) {
    if (result.indexOf(arr[i]) === -1) {
      result.push(arr[i]);
    }
  }
  return result;
}

//reduce方法
function uniqueReduce(arr){
    let result = arr.reduce((pre,cur)=>{
        if(pre.indexOf(cur) === -1){
            return pre.concat([cur]);
        }else{
            return pre;
        }
    },[])
    return result;
}

console.log(
  "set方法",
  uniqueSet([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 2, 1, 4, 5])
);
console.log(
  "indexOf方法",
  uniqueIndexOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 2, 1, 4, 5])
);
console.log(
  "reduce方法",
  uniqueReduce([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 2, 1, 4, 5])
);